/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author roycalderon
 */
@Entity
@Table(name = "knowledgeArea")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "KnowledgeArea.findAll", query = "SELECT k FROM KnowledgeArea k"),
    @NamedQuery(name = "KnowledgeArea.findByIdknowledgeArea", query = "SELECT k FROM KnowledgeArea k WHERE k.idknowledgeArea = :idknowledgeArea"),
    @NamedQuery(name = "KnowledgeArea.findByName", query = "SELECT k FROM KnowledgeArea k WHERE k.name = :name")})
public class KnowledgeArea implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idknowledgeArea")
    private Integer idknowledgeArea;
    @Size(max = 45)
    @Column(name = "Name")
    private String name;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "knowledgeArea", fetch = FetchType.LAZY)
    private List<Book> bookList;

    public KnowledgeArea() {
    }

    public KnowledgeArea(Integer idknowledgeArea) {
        this.idknowledgeArea = idknowledgeArea;
    }

    public Integer getIdknowledgeArea() {
        return idknowledgeArea;
    }

    public void setIdknowledgeArea(Integer idknowledgeArea) {
        this.idknowledgeArea = idknowledgeArea;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlTransient
    public List<Book> getBookList() {
        return bookList;
    }

    public void setBookList(List<Book> bookList) {
        this.bookList = bookList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idknowledgeArea != null ? idknowledgeArea.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof KnowledgeArea)) {
            return false;
        }
        KnowledgeArea other = (KnowledgeArea) object;
        if ((this.idknowledgeArea == null && other.idknowledgeArea != null) || (this.idknowledgeArea != null && !this.idknowledgeArea.equals(other.idknowledgeArea))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entities.KnowledgeArea[ idknowledgeArea=" + idknowledgeArea + " ]";
    }
    
}
